#pragma once

#include <memory>
#include <vector>
#include <string>
#include <optional>
#include "String.h"

class CHeadFile;
class CScriptToken;

class CTokenGenerator
{
public:    
    CTokenGenerator(CHeadFile* InContext);


    void GenerateTokens();

protected:
    //std::shared_ptr<CScriptToken> CreateToken(std::shared_ptr<CHeadFile> InContext,const C32String& InWord);

    //return true is no error
    bool TryCreateToken();

    //return true if successfullly create a token
    bool TryCreateKeywordToken(C32String InWord);

    CHeadFile* Context;


    std::size_t CharIndex=0;
    std::size_t LineIndex=0;  //start from 0
    std::size_t ColumnIndex=0; //start from 0

    char32_t GetCurrentChar() const;
    char32_t GetNextChar() const;   

    void GotoNextChar();

    std::optional<char32_t> ReadEscapeChar();
};